﻿using System;
using WAD.WEB.AppCode;
using WAD.DAL;

namespace WAD.WEB.Client.Ajax
{
    /// <summary>
    /// FC_Shared_Money 的摘要说明
    /// </summary>
    public class FC_Shared_Money : AjaxBase
    {
        public override void AjaxMethodDispatch(String identity)
        {
            switch (identity)
            {
                case "qiang": this.Qiang(); break;
            }
        }
        protected static object lockObj = new object();
        /// <summary>
        /// 抢红包
        /// </summary>
        [QD.Web.Ajax.AjaxMethod]
        public void Qiang()
        {
            IsLogin();
            int user_id = Parse.Int("user_id", 0);
            int article_id = Parse.Int("article_id", 0);
            int id = 0;
            lock (lockObj)
            {
                id = DAOFCSharedMoney.Qiang(user_id, article_id);   //添加名额
            }
            if (id > 1)
                JsonResult(0, "恭喜你，赶紧分享后领红包吧！", id);
            else if (id == 0)
                JsonResult(201, "不能重复抢");
            else if (id == -2)
                JsonResult(202, "账号未审核");
            else if (id < 1)
                JsonResult(203, "您下手慢了，没抢到名额！");
        }
    }
}